/**
 * Created by licc on 03/11/2020.
 * 与子应用通信都用这个vuex，弃用qiankun自带的initGlobalState
 */
import { VuexModule, Module, Mutation, Action, getModule } from 'vuex-module-decorators'
import store from '@/store'
export interface SheetRecordState {
  sheetRecordData: any
}

@Module({ dynamic: true, name: 'sheetRecord', store, namespaced: false })
class SheetRecord extends VuexModule implements SheetRecordState {
  public sheetRecordData = {
    applicationId: null,
    worksheetId: ''
  }

  get getSheetRecordData () {
    return this.sheetRecordData
  }

  @Mutation
  public setSheetRecordData (data: any) {
    this.sheetRecordData = data
  }

  @Action
  public handleCancelFunc () {
    console.log('点击了 [ 取消 ] 按钮')
  }

  /**
   * @param type 类型：add | edit
   */
  @Action
  public handleSaveFunc (type: string) {
    if (type === 'add') {
      console.log('点击了 [ 保存 ] 按钮，新增:\n', type)
    } else if (type === 'edit') {
      console.log('点击了 [ 保存 ] 按钮，编辑:\n', type)
    }
  }
}

export const SheetRecordModule = getModule(SheetRecord)
